home *** CD-ROM | disk | FTP | other *** search
/ Linux 68k 2000 / Linux 68k 2000.iso / dokus / Tips-HOWTO < prev    next >
Encoding:
Text File  |  1997-01-20  |  26.7 KB  |  669 lines

  1.   The Linux Tips HOWTO
  2.   Paul Anderson, paul@geeky1.ebtech.net
  3.   v3.0, 7 January 1997
  4.  
  5.   This HOWTO contains those hard to find hints and tweekings that make
  6.   Linux a bit nicer.
  7.  
  8.   1.  Introduction
  9.  
  10.   Welcome to the Linux Tips HOWTO, a list of neato tricks and
  11.   optimizations that make Linux more fun.  All I have in here right now
  12.   are tips off of the top of my head, and tips from the old Tips-
  13.   HOWTO(Why take out decent tips, right?).  So send all your favorite
  14.   hints and tips to me so I can put them in the next Tips-HOWTO.
  15.  
  16.   Paul Anderson Maintainer--Linux TIPS HOWTO
  17.  
  18.   panderso@ebtech.net
  19.  
  20.   2.  Short Tips
  21.  
  22.   2.1.  Handy Syslog Trick Paul Anderson, Tips-HOWTO maintainer
  23.  
  24.   Edit your /etc/syslog.conf, and put in the following line:
  25.  
  26.        # Dump everything on tty8
  27.        *.*                                     /dev/tty8
  28.  
  29.   One caveat: REMEMBER TO USE TABS!  syslog doesn't like spaces...
  30.  
  31.   2.2.  Script to view those compressed HOWTOs. Didier Juges,
  32.   dj@destin.nfds.net
  33.  
  34.   From a newbie to another, here is a short script that eases looking
  35.   for and viewing howto documents.  My howto's are in
  36.   /usr/doc/faq/howto/ and are gzipped. The file names are XXX-HOWTO.gz,
  37.   XXX being the subject.  I created the following script called "howto"
  38.   in the /usr/local/sbin directory:
  39.  
  40.        ______________________________________________________________________
  41.        #!/bin/sh
  42.        if [ "$1" = "" ]; then
  43.            ls /usr/doc/faq/howto | less
  44.        else
  45.            gunzip -c /usr/doc/faq/howto/$1-HOWTO.gz | less
  46.        fi
  47.        ______________________________________________________________________
  48.  
  49.   When called without argument, it displays a directory of the available
  50.   howto's. Then when entered with the first part of the file name
  51.   (before the hyphen) as an argument, it unzips (keeping the original
  52.   intact) then displays the document.
  53.  
  54.   For instance, to view the Serial-HOWTO.gz document, enter:
  55.  
  56.   $ howto Serial
  57.  
  58.   2.3.  Is there enough free space??? Hans Zoebelein,
  59.   zocki@goldfish.cube.net
  60.  
  61.   Here comes a short script which will check from time to time that
  62.   there is enough free space available on anything which shows up in
  63.   mount (disks, cdrom, floppy...)
  64.  
  65.   If space runs out, a message is printed every X seconds to the screen
  66.   and 1 mail message per filled device is fired up.
  67.  
  68.   ______________________________________________________________________
  69.   #!/bin/sh
  70.  
  71.   #
  72.   # $Id: check_hdspace,v 1.18 1996/12/11 22:33:29 root Exp root $
  73.   #
  74.  
  75.   #
  76.   # Since I got mysterious error messages during compile when
  77.   # tmp files filled up my disks, I wrote this to get a warning
  78.   # before disks are full.
  79.   #
  80.   # If this stuff saved your servers from exploding,
  81.   # send praising email to zocki@goldfish.cube.net.
  82.   # If your site burns down because of this, sorry but I
  83.   # warned you: no comps.
  84.   # If you really know how to handle sed, please forgive me :)
  85.   #
  86.  
  87.   #
  88.   # Shoot and forget: Put 'check_hdspace &' in rc.local.
  89.   # Checks for free space on devices every $SLEEPTIME sec.
  90.   # You even might check your floppies or tape drives. :)
  91.   # If free space is below $MINFREE (kb), it will echo a warning
  92.   # and send one mail for each triggering device to $MAIL_TO_ME.
  93.   # If there is more free space than trigger limit again,
  94.   # mail action is also armed again.
  95.   #
  96.  
  97.   # TODO: Different $MINFREE for each device.
  98.   # Free /*tmp dirs securely from old junk stuff if no more free space.
  99.  
  100.   DEVICES='/dev/sda2 /dev/sda8 /dev/sda9'         # device; your put disks here
  101.   MINFREE=20480                                   # kb; below this do warning
  102.   SLEEPTIME=10                                    # sec; sleep between checks
  103.   MAIL_TO_ME='root@localhost'                     # fool; to whom mail warning
  104.  
  105.   # ------- no changes needed below this line (hopefully :) -------
  106.  
  107.   MINMB=0
  108.   ISFREE=0
  109.   MAILED=""
  110.   let MINMB=$MINFREE/1024         # yep, we are strict :)
  111.  
  112.   while [ 1 ]; do
  113.           DF="`/bin/df`"
  114.                   for DEVICE in $DEVICES ; do
  115.                   ISFREE=`echo $DF | sed s#.\*$DEVICE" "\*[0-9]\*""\*[0-9]\*" "\*## | sed s#" ".\*##`
  116.  
  117.                   if [ $ISFREE -le $MINFREE ] ; then
  118.                           let ISMB=$ISFREE/1024
  119.                           echo  "WARNING: $DEVICE only $ISMB mb free." >&2
  120.                           #echo "more stuff here" >&2
  121.                           echo -e "\a\a\a\a"
  122.  
  123.                           if [ -z  "`echo $MAILED | grep -w $DEVICE`" ] ; then
  124.                                   echo "WARNING: $DEVICE only $ISMB mb free.      (Trigger is set to $MINMB mb)" \
  125.                                   | mail -s "WARNING: $DEVICE only $ISMB mb free!" $MAIL_TO_ME
  126.                                   MAILEDH="$MAILED $DEVICE"
  127.                                   MAILED=$MAILEDH
  128.                                   # put further action here like cleaning
  129.                                   # up */tmp dirs...
  130.                           fi
  131.                           elif [ -n  "`echo $MAILED | grep -w $DEVICE`" ] ; then
  132.                                   # Remove mailed marker if enough disk space
  133.                                   # again. So we are ready for new mailing action.
  134.                                   MAILEDH="`echo $MAILED  | sed s#$DEVICE##`"
  135.                                   MAILED=$MAILEDH
  136.                           fi
  137.  
  138.                   done
  139.                   sleep $SLEEPTIME
  140.  
  141.   done
  142.   ______________________________________________________________________
  143.  
  144.   2.4.  Util to clean up your logfiles. Paul Anderson, Tips-HOWTO Main¡
  145.   tainer>
  146.  
  147.   If you're like me, you have a list with 250 subscribers, plus 100+
  148.   messages per day coming in over UUCP.  Well, what's a hacker to do
  149.   with these huge logs?  Install chklogs, that's what.  Chklogs is
  150.   written by Emilio Grimaldo, grimaldo@panama.iaehv.nl, and the current
  151.   version 1.8 available from
  152.   ftp.iaehv.nl:/pub/users/grimaldo/chklogs-1.8.tar.gz.  It's pretty self
  153.   explanatory to install(you will, of course, check out the info in the
  154.   doc subdirectory).  Once you've got it installed, add a crontab entry
  155.   like this:
  156.  
  157.        # Run chklogs at 9:00PM daily.
  158.        00 21 * * *       /usr/local/sbin/chklogs -m
  159.  
  160.   While you're at it, mention to the author how nice a peice of software
  161.   this is:)
  162.  
  163.   2.5.  ohammers@cu-online.com Handy Script to Clean Up Corefiles. Otto
  164.   Hammersmith,
  165.  
  166.   Create a file called rmcores(the author calls it handle-cores) with
  167.   the following in it:
  168.  
  169.   ______________________________________________________________________
  170.   #!/bin/sh
  171.   USAGE="$0 <directory> <message-file>"
  172.  
  173.   if [ $# != 2 ] ; then
  174.           echo $USAGE
  175.           exit
  176.   fi
  177.  
  178.    echo Deleting...
  179.   find $1 -name core -atime 7 -print -exec rm {} \;
  180.  
  181.   echo e-mailing
  182.   for name in `find $1 -name core -exec ls -l {} \; | cut -c16-24`
  183.   do
  184.           echo $name
  185.           cat $2 | mail $name
  186.   done
  187.   ______________________________________________________________________
  188.  
  189.   And have a cron job run it every so often.
  190.  
  191.   2.6.  Moving directories between filesystems. Alan Cox,
  192.   A.Cox@swansea.ac.uk
  193.  
  194.   Quick way to move an entire tree of files from one disk to another
  195.  
  196.        (cd /source/directory && tar cf - . ) | (cd /dest/directory && tar xvfp -)
  197.  
  198.    Change from cd /source/directory; tar....etc.  to prevent possibility
  199.   of trashing directory in case of disaster.  Thanks to Jim Dennis,
  200.   jadestar@rahul.net, for letting me know. -Maint.
  201.  
  202.   2.7.  mghazey@miso.lowdown.com Finding out which directories are the
  203.   largest. Mick Ghazey,
  204.  
  205.   Ever wondered which directories are the biggest on your computer?
  206.   Here's how to find out.
  207.  
  208.        du -S | sort -n
  209.  
  210.   2.8.  The Linux Gazette
  211.  
  212.   Kudos go to John Fisk, creator of the Linux Gazette.  This is an
  213.   excellent e-zine plus, it's FREE!!!  Now what more could you ask?
  214.   Check it out at:
  215.  
  216.        http://www.ssc.com/lg
  217.  
  218.   BTW, It turns out that (1) LG is now out on a monthly basis, and (2)
  219.   John Fisk no longer maintains it, the fellows at SSC do.
  220.  
  221.   2.9.  Ted Stern, stern@amath.washington.edu Pointer to patch for GNU
  222.   Make 3.70 to change VPATH behavior.
  223.  
  224.   I don't know if many people have this problem, but there is a
  225.   "feature" of GNU make version 3.70 that I don't like. It is that VPATH
  226.   acts funny if you give it an absolute pathname.  There is an extremely
  227.   solid patch that fixes this, which you can get from Paul D. Smith
  228.   <psmith@wellfleet.com>.  He also posts the documentation and patch
  229.   after every revision of GNU make on the newsgroup system I have access
  230.   to.
  231.  
  232.   2.10.  How do I stop my system from fscking on each reboot? Dale Lutz,
  233.   dal@wimsey.com
  234.  
  235.   Q:  How do I stop e2fsck from checking my disk every time I boot up.
  236.  
  237.   A:  When you rebuild the kernel, the filesystem is marked as 'dirty'
  238.   and so your disk will be checked with each boot.  The fix is to run:
  239.  
  240.   rdev -R /zImage 1
  241.  
  242.   This fixes the kernel so that it is no longer convinced that the
  243.   filesystem is dirty.
  244.  
  245.   Note: If using lilo, then add read-only to your linux setup in your
  246.   lilo config file (Usually /etc/lilo.conf)
  247.  
  248.   2.11.  How to avoid fscks caused by "device busy" at reboot time. Jon
  249.   Tombs, jon@gtex02.us.es
  250.  
  251.   If you often get device busy errors on shutdown that leave the
  252.   filesystem in need of an fsck upon reboot, here is a simple fix:
  253.  
  254.   To /etc/rc.d/init.d/halt or /etc/rc.d/rc.0, add the line
  255.  
  256.        mount -o remount,ro /mount.dir
  257.  
  258.   for all your mounted filesystems except /, before the call to umount
  259.   -a. This means if, for some reason, shutdown fails to kill all pro¡
  260.   cesses and umount the disks they will still be clean on reboot. Saves
  261.   a lot of time at reboot for me.
  262.  
  263.   2.12.  How to find the biggest files on your hard-drive.
  264.  
  265.   Simon Amor, simon@foobar.co.uk
  266.  
  267.        ls -l | sort +4n
  268.  
  269.   Or, for those of you really scrunched for space this takes awhile but
  270.   works great:
  271.  
  272.        cd /
  273.        ls -lR | sort +4n
  274.  
  275.   2.13.  How to print pages with a margin for hole punching. Mike
  276.   Dickey, mdickey@thorplus.lib.purdue.edu
  277.  
  278.        ______________________________________________________________________
  279.                #!/bin/sh
  280.                # /usr/local/bin/print
  281.                # a simple formatted printout, to enable someone to
  282.                # 3-hole punch the output and put it in a binder
  283.  
  284.                cat $1 | pr -t -o 5 -w 85 | lpr
  285.        ______________________________________________________________________
  286.  
  287.   2.14.  Raul Deluth Miller, rockwell@nova.umd.edu A way to search
  288.   through trees of files for a particular regular expression.
  289.  
  290.   I call this script 'forall'.  Use it like this:
  291.  
  292.        forall /usr/include grep -i ioctl
  293.        forall /usr/man grep ioctl
  294.  
  295.   Here's forall:
  296.  
  297.        ______________________________________________________________________
  298.        #!/bin/sh
  299.        if [ 1 = `expr 2 \> $#` ]
  300.        then
  301.                echo Usage: $0 dir cmd [optargs]
  302.                exit 1
  303.        fi
  304.        dir=$1
  305.        shift
  306.        find $dir -type f -print | xargs "$@"
  307.        ______________________________________________________________________
  308.  
  309.   2.15.  Barry Tolnas, tolnas@nestor.engr.utk.edu A script for cleaning
  310.   up after programs that create autosave and backup files.
  311.  
  312.   Here is a simple two-liner which recursively descends a directory
  313.   hierarchy removing emacs auto-save (#) and backup (~) files, .o files,
  314.   and  TeX .log files. It also compresses .tex files and README files. I
  315.   call it 'squeeze' on my system.
  316.  
  317.        ______________________________________________________________________
  318.        #!/bin/sh
  319.        #SQUEEZE removes unnecessary files and compresses .tex and README files
  320.        #By Barry tolnas, tolnas@sun1.engr.utk.edu
  321.        #
  322.        echo squeezing $PWD
  323.        find  $PWD \( -name \*~ -or -name \*.o -or -name \*.log -or -name \*\#\) -exec
  324.        rm -f {} \;
  325.        find $PWD \( -name \*.tex -or -name \*README\* -or -name \*readme\* \) -exec gzip -9 {} \;
  326.        ______________________________________________________________________
  327.  
  328.   2.16.  simon@foobar.co.uk How to find out what process is eating the
  329.   most memory. Simon Amor,
  330.  
  331.        ps -aux | sort +4n
  332.  
  333.   -OR-
  334.  
  335.        ps -aux | sort +5n
  336.  
  337.   3.  Detailed Tips
  338.  
  339.   3.1.  Sharing swap partitions between Linux and Windows. Tony Acero,
  340.   ace3@midway.uchicago.edu
  341.  
  342.   1. Format the partition as a dos partition, and create the Windows
  343.      swap file on it, but don't run windows yet. (You want to keep the
  344.      swap file completely empty for now, so that it compresses well).
  345.  
  346.   2. Boot linux and save the partition into a file.  For example if the
  347.      partition was /dev/hda8:
  348.  
  349.        dd if=/dev/hda8 of=/etc/dosswap
  350.  
  351.   3. Compress the dosswap file; since it is virtually all 0's it will
  352.      compress very well
  353.  
  354.        gzip -9 /etc/dosswap
  355.  
  356.   4. Add the following to the /etc/rc file to prepare and install the
  357.      swap space under Linux:
  358.  
  359.      XXXXX is the number of blocks in the swap partition
  360.  
  361.        mkswap /dev/hda8 XXXXX
  362.        swapon -av
  363.  
  364.   Make sure you add an entry for the swap partition in your /etc/fstab
  365.   file
  366.  
  367.   5. If your init/reboot package supports /etc/brc or /sbin/brc add the
  368.      following to /etc/brc, else do this by hand when you want to boot
  369.      to dos|os/2 and you want to convert the swap partition back to the
  370.      dos/windows version:
  371.  
  372.        swapoff -av
  373.        zcat /etc/dosswap.gz | dd of=/dev/hda8 bs=1k count=100
  374.  
  375.   # Note that this only writes the first 100 blocks back to the parti¡
  376.   tion. I've found empirically that this is sufficient
  377.  
  378.   >>  What are the pros and cons of doing this?
  379.  
  380.   Pros: you save a substantial amount of disk space.
  381.  
  382.   Cons: if step 5 is not automatic, you have to remember to do it by
  383.   hand, and it slows the reboot process by a nanosecond :-)
  384.  
  385.   3.2.  Desperate Undelete. Michael Hamilton, michael@actrix.gen.nz
  386.  
  387.   Here's a trick I've had to use a few times.
  388.  
  389.   Desperate person's text file undelete.
  390.  
  391.   If you accidentally remove a text file, for example, some email, or
  392.   the results of a late night programming session, all may not be lost.
  393.   If the file ever made it to disk, ie it was around for more than 30
  394.   seconds, its contents may still be in the disk partition.
  395.  
  396.   You can use the grep command to search the raw disk partition for the
  397.   contents of file.
  398.  
  399.   For example, recently, I accidentally deleted a piece of email.  So I
  400.   immediately ceased any activity that could modify that partition: in
  401.   this case I just refrained from saving any files or doing any compiles
  402.   etc.  On other occasions, I've actually gone to the trouble of bring
  403.   the system down to single user mode, and unmounted the filesystem.
  404.  
  405.   I then used the egrep command on the disk partition:  in my case the
  406.   email message was in /usr/local/home/michael/, so from the output from
  407.   df, I could see this was in /dev/hdb5
  408.  
  409.     sputnik3:~ % df
  410.       Filesystem         1024-blocks  Used Available Capacity Mounted on
  411.       /dev/hda3              18621    9759     7901     55%   /
  412.       /dev/hdb3             308852  258443    34458     88%   /usr
  413.       /dev/hdb5             466896  407062    35720     92%   /usr/local
  414.  
  415.       sputnik3:~ % su
  416.       Password:
  417.       [michael@sputnik3 michael]# egrep -50 'ftp.+COL' /dev/hdb5 > /tmp/x
  418.  
  419.   Now I'm ultra careful when fooling around with disk partitions, so I
  420.   paused to make sure I understood the command syntax BEFORE pressing
  421.   return.  In this case the email contained the word 'ftp' followed by
  422.   some text followed by the word 'COL'.  The message was about 20 lines
  423.   long, so I used -50 to get all the lines around the phrase.  In the
  424.   past I've used -3000 to make sure I got all the lines of some source
  425.   code.  I directed the output from the egrep to a different disk parti¡
  426.   tion - this prevented it from over writing the message I was looking
  427.   for.
  428.  
  429.   I then used strings to help me inspect the output
  430.  
  431.           strings /tmp/x | less
  432.  
  433.   Sure enough the email was in there.
  434.  
  435.   This method can't be relied on, all, or some, of the disk space may
  436.   have already been re-used.
  437.  
  438.   This trick is probably only useful on single user systems.  On multi-
  439.   users systems with high disk activity, the space you free'ed up may
  440.   have already been reused.  And most of use can't just rip the box out
  441.   from under our users when ever we need to recover a file.
  442.  
  443.   On my home system this trick has come in handy on about three
  444.   occasions in the past few years - usually when I accidentally trash
  445.   some of the days work.  If what I'm working survives to a point where
  446.   I feel I made significant progress, it get's backed up onto floppy, so
  447.   I haven't needed this trick very often.
  448.  
  449.   3.3.  How to use the immutable flag. Jim Dennis, jadestar@rahul.net
  450.  
  451.   Use the Immutable Flag
  452.  
  453.   Right after you install and configure your system go through the /bin,
  454.   /sbin/, /usr/bin, /usr/sbin and /usr/lib (and a few of the other usual
  455.   suspects and make liberal use of the 'chattr +i command'.  Also add
  456.   that to the the kernel files in root.  Now 'mkdir /etc/.dist/' copy
  457.   everything from /etc/ on down (I do this in two steps using
  458.   /tmp/etcdist.tar to avoid recursion) into that directory.  (Optionally
  459.   you can just create /etc/.dist.tar.gz) -- and mark that as immutable.
  460.  
  461.   The reason for all of this is to limit the damage that you can do when
  462.   logged in as root.  You won't overwrite files with a stray redirection
  463.   operator, and you won't make the system unusable with a stray space in
  464.   an 'rm -fr' command (you might still do alot of damage to your data --
  465.   but your libs and bins will be safer.
  466.  
  467.   This also makes a variety of security and denial of service exploits
  468.   either impossible or more difficult (since many of them rely on
  469.   overwriting a file through the actions of some SUID program that
  470.   *isn't providing an arbitrary shell command*).
  471.  
  472.   The only inconvenience of this is when building and doing your 'make
  473.   install' on various sorts of system binaries.  On the other hand it
  474.   also prevents the 'make install' from over-writing the files.  When
  475.   you forget to read the Makefile and chattr -i the files that are to be
  476.   overwritten (and the directories to which you want to add files) --
  477.   the make fails, you just use the chattr command and rerun it.  You can
  478.   also take that opportunity to move your old bin's, libs, or whatever
  479.   into a .old/ directory or rename or tar them or whatever.
  480.  
  481.   3.4.  Jim Dennis, jadestar@rahul.net A suggestion for where to put new
  482.   stuff.
  483.  
  484.   All new stuff starts under /usr/local! or /usr/local/`hostname`
  485.  
  486.   If your distribution is one that leaves /usr/local empty then just
  487.   create your /usr/local/src, /usr/local/bin etc and use that.  If your
  488.   distribution puts things in the /usr/local tree than you may want to
  489.   'mkdir /usr/local/`hostname`' and give the 'wheel' group +w to it (I
  490.   also make it SUID and SGID to insure that each member of the wheel
  491.   group can only mess with their own files thereunder, and that all
  492.   files created will belong to the 'wheel' group.
  493.  
  494.   Now discipline yourself to *ALWAYS! ALWAYS! ALWAYS!* put new packages
  495.   under /usr/local/src/.from/$WHEREVER_I_GOT_IT/ (for the .tar or
  496.   whatever files) and build them  under /usr/local/src (or
  497.   .../$HOSTNAME/src).  Make sure that it installs under the local
  498.   hierarchy.  If it *absolutely must* be installed back in /bin or
  499.   /usr/bin or somewhere else -- put a symlink from the local heirarchy
  500.   to each element that when anywhere else.
  501.  
  502.   The reason for this -- even though it's more work -- is that it helps
  503.   isolate what has to be backed up and restored or reinstalled in the
  504.   event of a full re-install from the distribution medio (usually CD
  505.   these days).  By using a /usr/local/.from directory you also keep an
  506.   informal log of where your sources are coming from -- which helps when
  507.   you're looking for new updates -- and may be critical when monitoring
  508.   the security announcement lists.
  509.  
  510.   One of my systems at home (the one I'm calling from) was put together
  511.   before I adopted these policies for myself.  I still don't "know" all
  512.   the ways that it differs from the stock "as installed" system.  This
  513.   is despite the fact that I've done very little with my home system's
  514.   configuration and I'm the *only* person who ever uses it.
  515.  
  516.   By contrast the systems I've set up at work (when I was thrust into
  517.   the role of system administrator there) have all been configured this
  518.   way -- have been administered by many contractors and other MIS
  519.   people, and have had a large number of upgrades and package
  520.   installations.  Nonetheless I have a very good idea which precise
  521.   elements were put in *after* the initial installation and
  522.   configuration.
  523.  
  524.   3.5.  Converting all files in a directory to lowercase. Justin Dossey,
  525.   dossey@ou.edu
  526.  
  527.   I noticed a few overly difficult or unnecessary procedures recommended
  528.   in the 2c tips section of Issue 12.  Since there is more than one, I'm
  529.   sending it to you:
  530.  
  531.        ______________________________________________________________________
  532.        #!/bin/sh
  533.                 # lowerit
  534.                 # convert all file names in the current directory to lower case
  535.                 # only operates on plain files--does not change the name of directories
  536.                 # will ask for verification before overwriting an existing file
  537.                 for x in `ls`
  538.                   do
  539.                   if [ ! -f $x ]; then
  540.                     continue
  541.                     fi
  542.                   lc=`echo $x  | tr '[A-Z]' '[a-z]'`
  543.                   if [ $lc != $x ]; then
  544.                     mv -i $x $lc
  545.                   fi
  546.                   done
  547.        ______________________________________________________________________
  548.  
  549.   Wow.  That's a long script.  I wouldn't write a script to do that;
  550.   instead, I would use this command:
  551.  
  552.        for i in * ; do [ -f $i ] && mv -i $i `echo $i | tr '[A-Z]' '[a-z]'`;
  553.        done;
  554.  
  555.   on the command line.
  556.  
  557.   The contributor says he wrote the script how he did for
  558.   understandability (see below).
  559.  
  560.   On the next tip, this one about adding and removing users, Geoff is
  561.   doing fine until that last step.  Reboot?  Boy, I hope he doesn't
  562.   reboot every time he removes a user.  All you have to do is the first
  563.   two steps.  What sort of processes would that user have going, anyway?
  564.   An irc bot?  Killing the processes with a simple
  565.  
  566.        kill -9 `ps -aux |grep ^<username> |tr -s " " |cut -d " " -f2`
  567.  
  568.   Example, username is foo
  569.  
  570.        kill -9 `ps -aux |grep ^foo |tr -s " " |cut -d " " -f2`
  571.  
  572.   That taken care of, let us move to the forgotten root password.
  573.  
  574.   The solution given in the Gazette is the most universal one, but not
  575.   the easiest one.  With both LILO and loadlin, one may provide the boot
  576.   parameter "single" to boot directly into the default shell with no
  577.   login or password prompt.  From there, one may change or remove any
  578.   passwords before typing ``init 3``to start multiuser mode.  Number of
  579.   reboots: 1 The other way Number of reboots: 2
  580.  
  581.   Justin Dossey
  582.  
  583.   3.6.  Jim Dennis, jadestar@rahul.net Some tips for new sysadmins.
  584.  
  585.   Create and maintain a /README.`hostname` and/or a
  586.   /etc/README.`hostname` Or possibly /usr/local/etc/README.`hostname`
  587.   -Maint.
  588.  
  589.   Absolutely, from *day one* of administering a system take notes in an
  590.   online log file.  You might make Another way to do this is to write an
  591.   su or a sudo script that does something like:
  592.  
  593.                        function exit \
  594.                                { unset exit; exit; \
  595.                                  cat ~/tmp/session.$(date +%y%m%d) \
  596.                                  >> /README.$(hostname) && \
  597.                                  vi /README.$(hostname)
  598.                                  }
  599.                        script -a ~/tmp/session.$(date +%y%m%d)
  600.                        /bin/su.org -
  601.  
  602.   (use the typescript command to create a session log and create a
  603.   function to automate appending and updating the log).
  604.  
  605.   I'll admit that I haven't implemented this automation of policy --
  606.   I've just relied on self-discipline so far.  However I have been
  607.   toying with the idea (even to the point of prototyping the scripts and
  608.   shell functions as you see them).  One thing that holds me back on
  609.   this is the 'script' command itself.  I think I'll have to grab the
  610.   sources and add a couple of command line parameters (to pause/stop the
  611.   script recording from the command line) before I commit to using
  612.   this).
  613.  
  614.   My last suggestion (for this round):
  615.  
  616.   Root's path should consist of 'PATH= /bin'
  617.  
  618.   That's it.  Nothing else on root's path.  Everything root does is
  619.   provided by a symlink from  /bin or by an alias or shell function, or
  620.   is a script or binary in  /bin, or is typed out with an explicit path.
  621.  
  622.   This makes anyone running as root aware (sometimes painfully so) of
  623.   how he or she is trusting binaries.  The wise admin of a multi-user
  624.   host will periodically look through his or here  /bin and  /.*history
  625.   files to look for patterns and loopholes.
  626.  
  627.   The really motivated admin will spot sequences that can be automated,
  628.   places where sanity checks can be inserted, and tasks for which 'root'
  629.   privileges should be temporarily eschewed (launching editors, MTA's
  630.   and other large interactive programs with elaborate scripting features
  631.   that *might* be embedded in transparent or data files -- like the
  632.   infamous vi ./.exrc and emacs ./.emacs and the even more insidous
  633.   $EXINIT and the embedded header/footer macros).  Naturally those sorts
  634.   of commands can be run with something like:
  635.  
  636.                   cp $data $some_users_home/tmp
  637.                   su -c $origcommand $whatever_switches
  638.                   cp $some_users_home/tmp $data
  639.  
  640.   (...where the specifics depend on the command).
  641.  
  642.   Mostly these last sorts of precautions are overboard for the home or
  643.   "single" user workstation -- but they are very good policy the admin
  644.   of a multi-user -- particular a publicly exposed system (like the
  645.   one's at netcom).
  646.  
  647.   3.7.  How to configure xdm's chooser for host selection. Arrigo Tri¡
  648.   ulzi, a.triulzi@ic.ac.uk
  649.  
  650.   1. Edit the file that launches xdm most likely /etc/rc/rc.6 or
  651.      /etc/rc.local) so that it contains the following lines in the xdm
  652.      startup section.
  653.  
  654.        /usr/bin/X11/xdm
  655.        exec /usr/bin/X11/X -indirect hostname
  656.  
  657.   2. Edit /usr/lib/X11/xdm/Xservers and comment out the line which
  658.      starts the server on the local machine i.e. starting 0:
  659.  
  660.   3. Reboot the machine and you're home and away.
  661.  
  662.   I add this because when I was, desperately, trying to set it up for my
  663.   own subnet over here it took me about a week to suss out all the
  664.   problems.
  665.  
  666.   Caveat: with old SLS (1.1.1) for some reason you can leave a -nodaemon
  667.   after the xdm line -- this does NOT work for later releases.
  668.  
  669.